﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrainTechLLC.ThreadSafeObjects;
using System.Windows.Controls;
using System.Windows;
using WpfImageDuplicates;
using BrainTechLLC.WPF;
using BrainTechLLC;

namespace WebCamPlugin
{
    public class WebCamMenuItemRegisterer : IRegisterMenuOption
    {
        public WebCam3WindowHandler WebCam3Handler;

        public List<MenuItemAndMetadata> GetSharedMenuItems(PluginDefinitionLoadedBase pluginDefinition)
        {
            List<MenuItemAndMetadata> results = new List<MenuItemAndMetadata>();

            MenuItemAndMetadata menuItemResult = new MenuItemAndMetadata() { TopLevelMenu = "View" };
            MenuItem menuItem = new MenuItem() { Header = "View _Webcam", Name = "mnuViewWebCam" };
            menuItem.Click += new System.Windows.RoutedEventHandler(menuItem_Click);
            menuItemResult.MenuItem = menuItem;
            if (WebCam3Handler == null)
            {
                WebCam3Handler = new WebCam3WindowHandler(Window1.MainWindow);
            }

            results.Add(menuItemResult);

            return results;
        }

        public void ErrorReported(string errorString)
        {
            Console.WriteLine(errorString);
        }

        void menuItem_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            Commands.ViewWebCam3Command.Execute(WebCam3Handler, Window1.MainWindow, Window1.MainWindow.FilterHandler.CurrentFilterCollection.Collection);
        }        
    }
}
